package com.ctg.itrdc.imageconsole.data.dao.impl;

import org.springframework.stereotype.Component;

import com.ctg.itrdc.imageconsole.data.dao.IDockerAppImageDao;
import com.ctg.itrdc.paspsdk.data.dao.impl.BaseDaoImpl;

@Component("dockerAppImageDao")
public class DockerAppImageDaoImpl extends BaseDaoImpl implements IDockerAppImageDao{

	@Override
	public boolean deleteByDockerImageFileId(Long dockerImageFileId) {
		String sql = new String("DELETE FROM DOCKER_APP_IMAGE WHERE DOCKER_IMAGE_FILE_ID = ?");
		Object[] params = new Object[]{dockerImageFileId};
		int i = super.getJdbcTemplate().update(sql, params);
		if(i > 0)
			return true;
		else
			return false;
	}

	@Override
	public int countByDockerAppTypeId(Long dockerAppTypeId) {
		String sql = new String("SELECT COUNT(*) FROM DOCKER_APP_IMAGE WHERE DOCKER_APP_TYPE_ID = ?");
		Object[] params = new Object[]{dockerAppTypeId};
		return super.getJdbcTemplate().queryForObject(sql, params, Integer.class);
	}

	@Override
	public boolean deleteByDockerAppTypeId(Long dockerAppTypeId) {
		String sql = new String("DELETE FROM DOCKER_APP_IMAGE WHERE DOCKER_APP_TYPE_ID = ?");
		Object[] params = new Object[]{dockerAppTypeId};
		int i = super.getJdbcTemplate().update(sql, params);
		if(i > 0)
			return true;
		else
			return false;
	}

}
